//
//  HomeTotalPriceCell.m
//  ShandsMod
//
//  Created by zh_s on 3/17/23.
//  Copyright © 2023 zh_s. All rights reserved.
//

#import "HomeTotalPriceCell.h"

@interface HomeTotalPriceCell ()

@property (nonatomic, strong) UILabel *priceLab;
@property (nonatomic, strong) UIImageView *backImage;
/**! arrowImg*/
@property (nonatomic, strong) UIImageView *arrowImg;

@end

@implementation HomeTotalPriceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryNone;
        self.backgroundColor = [UIColor clearColor];
        [self createView];
    }
    return self;
}

- (void)createView {
    

//    [backV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(20);
//        make.width.mas_equalTo(SCREEN_WIDTH - 40);
//        make.top.mas_equalTo(0);
//        make.height.mas_offset(123);
//    }];
    
    UIView *backV = [[UIView alloc] init];
    [self.contentView addSubview:backV];
//    backV.backgroundColor = UIColor.redColor;
    backV.frame = CGRectMake(20, 0, SCREEN_WIDTH - 40, 123);

    UIImageView *backImage = [[UIImageView alloc] init];
    backImage.image = IMAGE_NAME(@"bg_home_wallet");
    backImage.contentMode = UIViewContentModeScaleAspectFill;
    backImage.clipsToBounds = YES;
    backImage.userInteractionEnabled = YES;
    [backV addSubview:backImage];
//    backImage.frame = CGRectMake(0, 0, SCREEN_WIDTH - 40, 120);
    [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.left.mas_equalTo(-10);
        make.right.mas_equalTo(backV.mas_right).mas_offset(20);
        make.height.mas_equalTo(120);
    }];
    _backImage = backImage;
    
//    UIImageView *bottomV = [[UIImageView alloc] init];
//    bottomV.image = IMAGE_NAME(@"");
//    [self.contentView addSubview:bottomV];
//    [bottomV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(67);
//        make.left.mas_equalTo(15);
//        make.right.mas_equalTo(backV.mas_right).mas_offset(-15);
//        make.height.mas_equalTo(41);
//    }];
    

    
    
    UILabel *titleLab = [[UILabel alloc] init];
    [backV addSubview:titleLab];
    titleLab.textColor = UIColor.whiteColor;
    titleLab.font = FONT_NAME(@"DINCond-Bold", 38);
    NSString *string = @"3464.22";
    _priceLab = titleLab;
    
    NSString *price = [string componentsSeparatedByString:@"."][0];
    NSString *other = [string componentsSeparatedByString:@"."][1];
    NSString *dot = @"";
    if (!IsStrEmpty(other)) {
        dot = @".";
    }
    
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@%@",price,dot,other]];
    [attStr addFont:FONT_NAME(@"DINCond-Bold", 38) substring:price];
    [attStr addFont:FONT_NAME(@"DINCond-Bold", 28) substring:other];
    titleLab.attributedText = attStr;
    
//    titleLab.text = @"3464.22";
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(24);
        make.top.mas_equalTo(16);
        make.height.mas_equalTo(53);
    }];
    
    UILabel *cntentLab = [[UILabel alloc] init];
    [backV addSubview:cntentLab];
    cntentLab.textColor = RGBA(255, 255, 255, 0.5);
    cntentLab.font = FONT_NAME(FONT_Regular, 12);
    cntentLab.text = @"我的资产($)";
    cntentLab.numberOfLines = 0;
    [cntentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(24);
        make.top.mas_equalTo(64);
        make.height.mas_equalTo(22);
    }];
//    self.contentLab = cntentLab;
    UIImageView *hidePriceImg = [[UIImageView alloc] init];
    [backV addSubview:hidePriceImg];
    hidePriceImg.image = IMAGE_NAME(@"icon_home_hide");
    [hidePriceImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(cntentLab.mas_right).mas_offset(3);
        make.width.height.mas_equalTo(12);
        make.centerY.mas_equalTo(cntentLab.mas_centerY);
    }];
    
    UIImageView *moreImg = [[UIImageView alloc] init];
    [backV addSubview:moreImg];
    moreImg.image = IMAGE_NAME(@"icon_home_more");
    [moreImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(backV.mas_right).mas_offset(-25);
        make.width.height.mas_equalTo(18);
        make.centerY.mas_equalTo(cntentLab.mas_centerY);
    }];
    _arrowImg = moreImg;
    
    UIView *hidePriceV = [[UIView alloc] init];
    [backV addSubview:hidePriceV];
    [hidePriceV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(24);
        make.top.mas_equalTo(64);
        make.height.mas_equalTo(22);
        make.width.mas_equalTo(SCREEN_WIDTH - 100);
    }];
    [hidePriceV addTapGestureTarget:self action:@selector(hidePriceClick)];
}

- (void)hidePriceClick {
    
    _priceLab.text = @"******";
}

- (void)setHomeModel:(GWHomeModel *)homeModel {
    _homeModel = homeModel;
    
}

- (void)setMineModel:(NSString *)mineModel {
    _mineModel = mineModel;
    _arrowImg.hidden = YES;
    _backImage.image = IMAGE_NAME(@"bg_walletList_nol");
    
}

@end
